﻿using MediatR;
using T.ApprovalRecord;
using T.Settlement.Read.API.Application.Command.PaymentCommand;
using T.Settlement.Repository.SettlementInterface;

namespace T.Settlement.Read.API.Application.CommandHandlers.PaymentJandler
{
    public class PaymentApprovalBackfillCommandHandler : IRequestHandler<PaymentApprovalBackfillCommand, List<ApprovalRecordd>>
    {
        private readonly IApprovalRecorddSRepository _approvalRecorddSRepository;
        public PaymentApprovalBackfillCommandHandler(IApprovalRecorddSRepository approvalRecorddSRepository)
        {
            _approvalRecorddSRepository = approvalRecorddSRepository;
        }

        public async Task<List<ApprovalRecordd>> Handle(PaymentApprovalBackfillCommand request, CancellationToken cancellationToken)
        {
            return (await _approvalRecorddSRepository.GetAllAsync()).Where(x=>x.PaymentId == request.PaymentId).ToList();
        }
    }
}
